﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script src="../scripts/boot.js" type="text/javascript"></script>
    <script type="text/javascript">
         $.ajax({
             url: "../data/system.aspx?method=106",
             async: false,
             success: function (text) {
                 if (text == "no")
                     window.location = "../system/error.html";
                 else if (text == "out") {
                     var loginWindow = parent.mini.get("loginWindow");
                     if (!loginWindow.visible)
                         loginWindow.show();
                     var tabs = parent.mini.get("mainTabs");
                     var tab = tabs.getTab("tab$106");
                     tabs.removeTab(tab);
                 }
             }
        });
        var States = [{ id: 0, text: '未审核' }, { id: 1, text: '已审通过' }, { id: 2, text: '已审未通过' }, { id: -1, text: "全部"}];
        var State = [{ id: 0, text: '未审核' }, { id: 1, text: '<font color="Green">已审通过</font>' }, { id: 2, text: '<font color="Red">已审未通过</font>'}];
    </script>
</head>
<body>
    <div class="mini-fit" >
        <div id="divList" class="mini-fit" >
            <div class="mini-toolbar" style="border-bottom:0;">
                <table>
                    <tr>
                        <td>
                            单位名称:
                            <input id="key" class="mini-textbox" style="width:100px" emptytext="关键字"/>
                            类型:
                            <input id="state" class="mini-combobox" data="States" value="0" style="width:100px"/>
                            发布日期：
                            <input id="sdate" class="mini-datepicker"/>
                            至
                            <input id="edate" class="mini-datepicker"/>
                            <a class="mini-button" iconCls="icon-search" plain="true" onclick="search()">查询</a>
                            <span class="separator"></span>
                            <a class="mini-button" plain="true" iconcls="icon-ok" onclick="checkRows(1)">审核通过</a>
                            <a class="mini-button" plain="true" iconcls="icon-no" onclick="checkRows(2)">审核不通过</a>
                            <a class="mini-button" plain="true" iconcls="icon-remove" onclick="delRows()">删除</a>
                            <span class="separator"></span>
                            <a class="mini-button" plain="true" iconcls="icon-excel" onclick="excelRow()">查询结果导出</a>
                        </td>
                    </tr>
                </table>
            </div>
            <div class="mini-fit">
                <div id="datagrid1" class="mini-datagrid" style="width:100%;height:100%;" allowresize="true" url="../data/system.aspx?method=GetShopWindowList" idField="id" multiSelect="true" sizeList="[15,20,50,100]" pageSize="15">
                    <div property="columns">
                        <div type="checkcolumn"></div>
                        <div cellCls="actionIcons" name="action" width="50px" headerAlign="center" align="center" renderer="onActionRenderer" cellStyle="padding:0;">操作</div>
                        <div field="sw_name" headerAlign="center" align="center" allowSort="true" renderer="onCNameRenderer">单位名称</div>
                        <div field="sw_contact" headerAlign="center" align="center" >联系人</div>
                        <div field="sw_tel" headerAlign="center" align="center" >电话</div>
                        <div field="sw_state" width="80px" headerAlign="center" align="center" allowSort="true" renderer="onPastRenderer" >状态</div>
                        <div field="sw_inserttime" width="80px" allowSort="true" align="center" headerAlign="center" dateFormat="yyyy-MM-dd">发布时间</div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!--导出Excel相关HTML-->
     <form id="excelForm" action="../data/download.aspx?method=ExcelShopWindow" method="post" target="excelIFrame">
        <input type="hidden" name="sdate" id="Hidden1" />
        <input type="hidden" name="edate" id="Hidden2" />
    </form>
    <iframe id="excelIFrame" name="excelIFrame" style="display:none;"></iframe>
<script type="text/javascript">
    $.ajaxSetup({
        contentType: "application/x-www-form-urlencoded;charset=utf-8",
        complete: function (XMLHttpRequest, textStatus) {
            if (XMLHttpRequest.responseText == "out") {
                var loginWindow = parent.mini.get("loginWindow");
                if (!loginWindow.visible)
                    loginWindow.show();
            }
        }
    });

    mini.parse();

    var grid = mini.get("datagrid1");
    search();

    function search() {
        var key = mini.get("key").getValue();
        var state = mini.get("state").getValue();
        var sdate = mini.get("sdate").getText();
        var edate = mini.get("edate").getText();
        $("#Hidden1").val(sdate);
        $("#Hidden2").val(edate);
        grid.load({ key: key, state: state, sdate: sdate, edate: edate });
        grid.sortBy("sw_no", "desc");
    }

    function onActionRenderer(e) {
        var record = e.record;
        var s = '<span class="icon-word actionspan" title="下载" onclick="editRow(' + record._uid + ')"></span><span class="separator"></span><span class="icon-remove actionspan" title="删除" onclick="delRow(' + record._uid + ')"></span>';
        return s;
    }

    function onNameRenderer(e) {
        //var s = '<a class="linelink" href="../../Web/Job/' + e.record.re_no + '.html" target="_blank">' + e.record.re_name + '</a>';
        var s = '<a class="linelink">' + e.record.re_name + '</a>';
        if (e.record.re_hide == 1)
            s = s + "<span style='color:Red'>[隐]</span>";
        var myDate = new Date();

        if (e.record.re_endtime < myDate)
            s = s + "<span style='color:#0088ff'>[过期]</span>";
        return s;
    }

    function onCNameRenderer(e) {
        //var s = '<a class="linelink" href="../../Web/Company/' + e.record.re_cuno + '.html" target="_blank">' + e.record.cu_name + '</a>';
        var s = '<a class="linelink">' + e.record.cu_name + '</a>';
//        if (e.record.cu_hide == 1)
//            s = s + "<span style='color:red'>[隐]</span>";
//        var myDate = new Date();

//        if (e.record.cu_endtime < myDate)
//            s = s + "<span style='color:#0088ff'>[过期]</span>";
        return s;
    }

    function onPastRenderer(e) {
        for (var i = 0; i < State.length; i++) {
            var s = State[i];
            if (s.id == e.value)
                return s.text;
        }
        return "";
    }
    function editRow(row_uid) {
        var row = grid.getRowByUID(row_uid);
        if (row) {
            window.open(row.sw_url); 
        }
    }
    function delRow(row_uid) {
        var row = grid.getRowByUID(row_uid);
        if (row) {
            mini.confirm("确定删除此橱窗招聘吗？", "系统提示",
                function (action) {
                    if (action == "ok") {
                        mini.mask({ el: document.body, cls: 'mini-mask-loading', html: '删除中，请稍后...' });
                        $.ajax({
                            url: "../data/system.aspx?method=DeleteShopWindow",
                            data: { id: row.sw_no },
                            success: function (ret) {
                                mini.unmask(document.body);
                                if (ret == "out") {
                                    var loginWindow = parent.mini.get("loginWindow");
                                    if (!loginWindow.visible)
                                        loginWindow.show();
                                    return;
                                }
                                if (ret >= 0) {
                                    ShowMessage("系统提示", "删除成功！", 1);
                                    grid.reload();
                                }
                                else
                                    ShowMessage("系统提示", "删除失败！", 3);
                            },
                            error: function (XMLHttpRequest, textStatus, errorThrown) {
                                mini.unmask(document.body);
                                ShowMessage("系统提示", "删除失败！", 3);
                            }
                        });
                    }
                }
            );
        }
    }

    function delRows() {
        var rows = grid.getSelecteds();
        if (rows.length > 0) {
            mini.confirm("确定删除所选的橱窗招聘吗？", "系统提示",
                function (action) {
                    if (action == "ok") {
                        mini.mask({ el: document.body, cls: 'mini-mask-loading', html: '删除中，请稍后...' });
                        var ids = "";
                        for (var i = 0; i < rows.length; i++) {
                            ids += rows[i].sw_no + ',';
                        }

                        $.ajax({
                            url: "../data/system.aspx?method=DeleteShopWindow",
                            type: "post",
                            data: { id: ids },
                            success: function (ret) {
                                mini.unmask(document.body);
                                if (ret == "out") {
                                    var loginWindow = parent.mini.get("loginWindow");
                                    if (!loginWindow.visible)
                                        loginWindow.show();
                                    return;
                                }
                                if (ret >= 0) {
                                    ShowMessage("系统提示", "删除成功！", 1);
                                    grid.reload();
                                }
                                else
                                    ShowMessage("系统提示", "删除失败！", 3);
                            },
                            error: function (XMLHttpRequest, textStatus, errorThrown) {
                                mini.unmask(document.body);
                                ShowMessage("系统提示", "删除失败！", 3);
                            }
                        });
                    }
                }
            );
        } else
                ShowMessage("系统提示", "请选择需要删除的橱窗招聘！", 2);
    }


    //批量审核
    function checkRows(state) {
        var rows = grid.getSelecteds();
        if (rows.length > 0) {
            mini.confirm("确定要审核所选的橱窗招聘吗？", "系统提示",
                function (action) {
                    if (action == "ok") {
                        mini.mask({ el: document.body, cls: 'mini-mask-loading', html: '操作中，请稍后...' });
                        var ids = "";
                        for (var i = 0; i < rows.length; i++) {
                            ids += rows[i].sw_no + ',';
                        }

                        $.ajax({
                            url: "../data/system.aspx?method=CheckShopWindow",
                            type: "post",
                            data: { id: ids, state: state },
                            success: function (ret) {
                                mini.unmask(document.body);
                                if (ret == "out") {
                                    var loginWindow = parent.mini.get("loginWindow");
                                    if (!loginWindow.visible)
                                        loginWindow.show();
                                    return;
                                }
                                if (ret >= 0) {
                                    ShowMessage("系统提示", "审核成功！", 1);
                                    grid.reload();
                                }
                                else
                                    ShowMessage("系统提示", "审核失败！", 3);
                            },
                            error: function (XMLHttpRequest, textStatus, errorThrown) {
                                mini.unmask(document.body);
                                ShowMessage("系统提示", "审核失败！", 3);
                            }
                        });
                    }
                }
            );
        } else
                ShowMessage("系统提示", "请选择需要审核的橱窗招聘！", 2);
        }

        function excelRow() {
            mini.confirm("确定导出橱窗招聘情况吗？", "系统提示",
                function (action) {
                    if (action == "ok") {
                        $("#excelForm").submit();
                    }
                }
            );
        }
 </script>
</body>
</html>


